﻿//===============================================================================
//	CAskMissionComplete
//	返回任务完成
//===============================================================================

#include "CAskMissionComplete.h"
#include "Fixed1024.h"

//-------------------------------------------------------------------------------
CAskMissionComplete::CAskMissionComplete(uint32_t uid, uint32_t pn)
	: BaseMessage(uid, pn)
{
	_safe_guard_begin;
	_safe_guard_end;
}

//-------------------------------------------------------------------------------
CAskMissionComplete::~CAskMissionComplete(void)
{

}

void checkState(PlayerFixedIntegerArray * msState, uint32_t id);
//-------------------------------------------------------------------------------
void CAskMissionComplete::SetMissionCompleteState(PlayerFixedIntegerArray * msState
	, uint32_t id)
{
	_safe_guard_begin;

	checkState(msState, id);

	Json::Value jv;
	jv.clear();
	for (uint16_t i = Fixed1024::MISSION_STATE_START; i < Fixed1024::MISSION_STATE_END; i++)
	{
		uint32_t value = msState->GetValue(i);
		jv.append(value);
	}

	m_jv["mState"] = jv;
	m_jv["ret"] = 0;

	_safe_guard_end;
}

//	检查重置当前任务不可接状态
void checkState(PlayerFixedIntegerArray * msState, uint32_t id)
{

	uint32_t _idx = 0;
	uint32_t _start = 0;
	uint32_t _size = 0;
	
	bool	_set = false;

	switch (id)
	{
	case 501:
		//	S00501_STATE = {256, 0, 4}
		_idx = 256;
		_start = 0;
		_size = 4;

		_set = true;
		break;

	case 502:
		//	S00502_STATE = {256, 4, 4}
		_idx = 256;
		_start = 4;
		_size = 4;

		_set = true;
		break;

	case 503:
		//	S00503_STATE = {256, 8, 4}
		_idx = 256;
		_start = 8;
		_size = 4;

		_set = true;
		break;

	case 504:
		//	S00504_STATE = {256, 12, 4}
		_idx = 256;
		_start = 12;
		_size = 4;

		_set = true;
		break;

	case 505:
		//	S00505_STATE = {256, 16, 4}
		_idx = 256;
		_start = 16;
		_size = 4;

		_set = true;
		break;

	case 506:
		//	S00506_STATE = {256, 20, 4}
		_idx = 256;
		_start = 20;
		_size = 4;

		_set = true;
		break;

	case 507:
		//	S00507_STATE = {256, 24, 4}
		_idx = 256;
		_start = 24;
		_size = 4;

		_set = true;
		break;

	case 508:
		//	S00508_STATE = {256, 28, 4}
		_idx = 256;
		_start = 28;
		_size = 4;

		_set = true;
		break;

	case 509:
		//	S00509_STATE = {257, 0, 4}
		_idx = 257;
		_start = 0;
		_size = 4;

		_set = true;
		break;

	case 510:
		//	S00510_STATE = {257, 4, 4}
		_idx = 257;
		_start = 4;
		_size = 4;

		_set = true;
		break;

	case 511:
		//	S00511_STATE = {257, 8, 4}
		_idx = 257;
		_start = 8;
		_size = 4;

		_set = true;
		break;

	case 512:
		//	S00512_STATE = {257, 12, 4}
		_idx = 257;
		_start = 12;
		_size = 4;

		_set = true;
		break;

	case 513:
		//	S00513_STATE = {257, 16, 4}
		_idx = 257;
		_start = 16;
		_size = 4;

		_set = true;
		break;

	case 514:
		//	S00514_STATE = {257, 20, 4}
		_idx = 257;
		_start = 20;
		_size = 4;

		_set = true;
		break;

	case 515:
		//	S00515_STATE = {257, 24, 4}
		_idx = 257;
		_start = 24;
		_size = 4;

		_set = true;
		break;

	case 516:
		//	S00516_STATE = {257, 28, 4}
		_idx = 257;
		_start = 28;
		_size = 4;

		_set = true;
		break;

	case 517:
		//	S00517_STATE = {258, 0, 4}
		_idx = 258;
		_start = 0;
		_size = 4;

		_set = true;
		break;

	case 518:
		//	S00518_STATE = {258, 4, 4}
		_idx = 258;
		_start = 4;
		_size = 4;

		_set = true;
		break;

	case 519:
		//	S00519_STATE = {258, 8, 4}
		_idx = 258;
		_start = 8;
		_size = 4;

		_set = true;
		break;

	case 520:
		//	S00520_STATE = {258, 12, 4}
		_idx = 258;
		_start = 12;
		_size = 4;

		_set = true;
		break;

	case 521:
		//	S00521_STATE = {258, 16, 4}
		_idx = 258;
		_start = 16;
		_size = 4;

		_set = true;
		break;

	case 522:
		//	S00522_STATE = {258, 20, 4}
		_idx = 258;
		_start = 20;
		_size = 4;

		_set = true;
		break;

	case 523:
		//	S00523_STATE = {258, 24, 4}
		_idx = 258;
		_start = 24;
		_size = 4;

		_set = true;
		break;

	case 524:
		//	S00524_STATE = {258, 28, 4}
		_idx = 258;
		_start = 28;
		_size = 4;

		_set = true;
		break;

	case 525:
		//	S00525_STATE = {259, 0, 4}
		_idx = 259;
		_start = 0;
		_size = 4;

		_set = true;
		break;

	case 526:
		//	S00526_STATE = { 259, 4, 4 }
		_idx = 259;
		_start = 4;
		_size = 4;

		_set = true;
		break;

	case 527:
		//	S00527_STATE = {259, 8, 4}
		_idx = 259;
		_start = 8;
		_size = 4;

		_set = true;
		break;

	case 528:
		//	S00528_STATE = {259, 12, 4}
		_idx = 259;
		_start = 12;
		_size = 4;

		_set = true;
		break;

	case 529:
		//	S00529_STATE = {259, 16, 4}
		_idx = 259;
		_start = 16;
		_size = 4;

		_set = true;
		break;

	case 530:
		//	S00530_STATE = {259, 20, 4}
		_idx = 259;
		_start = 20;
		_size = 4;

		_set = true;
		break;

	case 531:
		//	S00531_STATE = {259, 24, 4}
		_idx = 259;
		_start = 24;
		_size = 4;

		_set = true;
		break;

	case 532:
		//	S00532_STATE = {259, 28, 4}
		_idx = 259;
		_start = 28;
		_size = 4;

		_set = true;
		break;

	case 533:
		//	S00533_STATE = {260, 0, 4}
		_idx = 260;
		_start = 0;
		_size = 4;

		_set = true;
		break;

	case 534:
		//	S00534_STATE = {260, 4, 4}
		_idx = 260;
		_start = 4;
		_size = 4;

		_set = true;
		break;

	case 535:
		//	S00535_STATE = {260, 8, 4}
		_idx = 260;
		_start = 8;
		_size = 4;

		_set = true;
		break;

	case 536:
		//	S00536_STATE = {260, 12, 4}
		_idx = 260;
		_start = 12;
		_size = 4;

		_set = true;
		break;

	case 537:
		//	S00537_STATE = {260, 16, 4}
		_idx = 260;
		_start = 16;
		_size = 4;

		_set = true;
		break;

	case 538:
		//	S00538_STATE = {260, 20, 4}
		_idx = 260;
		_start = 20;
		_size = 4;

		_set = true;
		break;

	case 539:
		//	S00539_STATE = {260, 24, 4}
		_idx = 260;
		_start = 24;
		_size = 4;

		_set = true;
		break;

	case 540:
		//	S00540_STATE = {260, 28, 4}
		_idx = 260;
		_start = 28;
		_size = 4;

		_set = true;
		break;

	case 541:
		//	S00541_STATE = {261, 0, 4}
		_idx = 261;
		_start = 0;
		_size = 4;

		_set = true;
		break;

	case 542:
		//	S00542_STATE = {261, 4, 4}
		_idx = 261;
		_start = 4;
		_size = 4;

		_set = true;
		break;

	case 543:
		//	S00543_STATE = {261, 8, 4}
		_idx = 261;
		_start = 8;
		_size = 4;

		_set = true;
		break;

	case 544:
		//	S00544_STATE = {261, 12, 4}
		_idx = 261;
		_start = 12;
		_size = 4;

		_set = true;
		break;

	case 545:
		//	S00545_STATE = {261, 16, 4}
		_idx = 261;
		_start = 16;
		_size = 4;

		_set = true;
		break;

	case 546:
		//	S00546_STATE = {261, 20, 4}
		_idx = 261;
		_start = 20;
		_size = 4;

		_set = true;
		break;

	case 547:
		//	S00547_STATE = {261, 24, 4}
		_idx = 261;
		_start = 24;
		_size = 4;

		_set = true;
		break;

	case 548:
		//	S00548_STATE = {261, 28, 4}
		_idx = 261;
		_start = 28;
		_size = 4;

		_set = true;
		break;

	case 549:
		//	S00549_STATE = {262, 0, 4}
		_idx = 262;
		_start = 0;
		_size = 4;

		_set = true;
		break;

	case 550:
		//	S00550_STATE = {262, 4, 4}
		_idx = 262;
		_start = 4;
		_size = 4;

		_set = true;
		break;

	case 551:
		//	S00551_STATE = {262, 8, 4}
		_idx = 262;
		_start = 8;
		_size = 4;

		_set = true;
		break;

	case 552:
		//	S00552_STATE = {262, 12, 4}
		_idx = 262;
		_start = 12;
		_size = 4;

		_set = true;
		break;

	case 553:
		//	S00553_STATE = {262, 16, 4}
		_idx = 262;
		_start = 16;
		_size = 4;

		_set = true;
		break;

	case 554:
		//	S00554_STATE = {262, 20, 4}
		_idx = 262;
		_start = 20;
		_size = 4;
		_set = true;
		break;

	case 555:
		//	S00555_STATE = {262, 24, 4}
		_idx = 262;
		_start = 24;
		_size = 4;

		_set = true;
		break;

	case 556:
		//	S00556_STATE = {262, 28, 4}
		_idx = 262;
		_start = 28;
		_size = 4;
		_set = true;
		break;

	case 557:
		//	S00557_STATE = {263, 0, 4}
		_idx = 263;
		_start = 0;
		_size = 4;

		_set = true;
		break;

	case 558:
		//	S00558_STATE = {263, 4, 4}
		_idx = 263;
		_start = 4;
		_size = 4;

		_set = true;
		break;

	case 559:
		//	S00559_STATE = {263, 8, 4}
		_idx = 263;
		_start = 8;
		_size = 4;

		_set = true;
		break;

	default:
		break;
	}

	if (_set)
	{
		uint32_t _state = msState->GetBitValue(_idx, _start, _size);
		if (0 == _state)
		{
			msState->SetBitValue(_idx, _start, _size, 1);
		}
	}
}

//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
